#!/bin/sh
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

for FILE in $(git diff --name-only --cached --)
do
    # 过滤掉 check-conflict.sh 文件
    if [ "$FILE" = ".husky/check-conflict" ]; then
        continue
    fi
    
    if grep "console.log" "$FILE";
    then 
        printf "\n"
        echo "${red}$FILE 中存在'console.log'，请删除后重新提交！${reset}"
        printf "\n"
        exit 1
    fi
    if grep "<<<<<<< HEAD" "$FILE";
    then 
        printf "\n"
        echo "${red}$FILE 中存在未解决的冲突，请解决后重新提交！${reset}"
        printf "\n"
        exit 1
    fi
done

exit
